﻿@{
    Layout = "~/Views/Shared/_LayuiLayout.cshtml";
}
<form class="layui-form layui-form-pane">
    <input type="hidden" name="ID" value="@Model.ID" />

    <div class="layui-form-item">
        <label class="layui-form-label">地区名称</label>
        <div class="layui-input-block">
            <input type="text" autocomplete="off" placeholder="请输入名称" class="layui-input"
                   lay-verify="required" name="Name" value="@Model.Name">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地区编码</label>
        <div class="layui-input-block">
            <input type="text" autocomplete="off" placeholder="请输入地区编码" class="layui-input" lay-verify="required" name="Code" value="@Model.Code">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">上级编码</label>
        <div class="layui-input-block">
            <input type="text" autocomplete="off" placeholder="请输入上级编码" class="layui-input" lay-verify="required" name="ParentID" value="@Model.ParentID">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">深度</label>
        <div class="layui-input-block">
            <input type="text" autocomplete="off" placeholder="请输入深度" class="layui-input" lay-verify="required|number" name="Deep" value="@Model.Deep">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">简拼</label>
        <div class="layui-input-block">
            <input type="text" autocomplete="off" placeholder="请输入简拼" class="layui-input" lay-verify="" name="Initials" value="@Model.Initials">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">热点</label>
        <div class="layui-input-block">
            <input type="checkbox" @(Model.Hot == true ? "checked" : "") name="Hot" lay-skin="switch" lay-filter="switchHot" value="true" title="开关" lay-text="是|否">
        </div>
    </div>
    <div class="layui-form-item " align="center">
        <button type="button" class="layui-btn" lay-submit="" lay-filter="Save">保存</button>
        <button type="button" class="layui-btn layui-btn-primary" id="btnCancel">取消</button>
    </div>
</form>

@section scripts{
<script type="text/javascript">
    var $, layer;
    layui.use(['form'], function () {
        var form = layui.form;
        $ = layui.jquery;
        layer = parent.layer === undefined ? layui.layer : parent.layer;

        // 监听关闭
        $('#btnCancel').on('click', function () {
            layer_close();
        });

        //监听提交
        form.on('submit(Save)', function (data) {
            $.post('@Url.Action("AddOrEdit", "Place")', data.field, function (msg) {
                if (msg.Success) {
                    parent.layer.msg(msg.Message, { icon: 1, time: 2000 });
                    parent.reload();
                    layer_close();
                } else {
                    layer.alert(msg.Message, { icon: 2 });
                }
            });
            return false;
        });


    });
</script>
    }


